package org.lizar.util;

import java.io.File;
import java.io.StringWriter;

import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

public class VelocityHelper {

	
	public static String read_msg(String template,VelocityContext context){
		  // 初始化并取得Velocity引擎
		  VelocityEngine ve = new VelocityEngine();
		  ve.init();
		  File file=new File(template);
		  String templategetStr=FileTool.read_it(file);
		  // 输出流
		  StringWriter writer = new StringWriter();
		  // 转换输出
		  ve.evaluate(context, writer, "", templategetStr); // 关键方法
		  return writer.toString();
	}
	
}
